package com.atstudy.other;

import java.io.IOException;

/**
 * @version v1.0
 * @description:
 * @author: admin
 * @date: 2022/12/23 15:46
 * @copyright: 博为峰
 */
public class DaemonDemo extends Thread {
    @Override
    public void run() {
        try {
            Thread.sleep(1000000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName());
    }

    public static void main(String[] args) throws IOException {
        /*
            1.用户线程
            2.守护线程（后台线程） 如果JVM进程中都是守护线程时，JVM退出
         */
        DaemonDemo daemonDemo = new DaemonDemo();
        daemonDemo.setDaemon(true);//守护线程
        daemonDemo.start();

        System.in.read();
    }
}
